gtest_dep = dependency('gtest', required: false)

# 构建测试工具库
subdir('drivers/test_utils')

test_sources = [
  'main.cpp',
  'drivers/pcie_nic_card/hisi/hi182x/test_hi182x_abi.cpp',
  'drivers/pcie_nic_card/hisi/hi182x/test_hi182x_card.cpp',
  'drivers/pcie_nic_card/hisi/hi182x/test_hi182x_port.cpp',
  'drivers/pcie_nic_card/hisi/hi182x/test_hi182x_om.cpp',
  'drivers/internal/bus/test_bus_i2c_mux.cpp',
  'drivers/internal/test_utils/mock_bus.cpp',
  'libraries/mctp/interface/PCIeEndpoint.cpp',
  'libraries/mctp/Endpoint.cpp',
  'libraries/smbus/chip_mock.cpp',
  'libraries/smbus/interface/i_mock_chip.cpp',
  'libraries/ipmb/test_ipmb.cpp',
  'libraries/imu/test_imu.cpp',
] + chip_interface_sources + blockio_interface_sources

test_mctp = [
  'main.cpp',
  'libraries/mctp/test_mctp_service.cpp',
  'libraries/mctp/interface/PCIeEndpoint.cpp',
  'libraries/mctp/Endpoint.cpp',
]

test_smbus = [
  'main.cpp',
  'libraries/smbus/test_std_smbus.cpp',
  'libraries/smbus/chip_mock.cpp',
  'libraries/smbus/interface/i_mock_chip.cpp',
] + chip_interface_sources + blockio_interface_sources

include_dirs += include_directories('../drivers/pcie_nic_card/hisi')
include_dirs += include_directories('../libraries')
include_dirs += include_directories('../drivers')
include_dirs += include_directories('../drivers/bus/i2c')
include_dirs += include_directories('../drivers/bus/hisport')
include_dirs += include_directories('../drivers/internal')
include_dirs += include_directories('../drivers/chip')

if meson_build
  include_dirs += include_directories('drivers/bus/hisport')
  include_dirs += include_directories('drivers/bus/i2c')
endif

libraries_dep = [libncsi_over_mctp_dep, libmctp_dep, libimu_dep, libsmbus_dep, ipmb_dep]

drivers_dep = [libhisi_182x_static, internal_static_lib]

component_drivers_test = executable(
  'component_drivers_test',
  test_sources,
  include_directories: include_dirs + 'libraries/smbus',
  dependencies: [gtest_dep, dev_deps, test_utilities_dep, test_utils_dep] + libraries_dep,
  link_whole: drivers_dep,
)

mctp_service_test = executable(
  'mctp_service_test',
  test_mctp,
  include_directories: include_dirs,
  dependencies: [gtest_dep, dev_deps, test_utilities_dep, test_utils_dep] + libraries_dep,
  link_whole: drivers_dep,
)

smbus_test = executable(
  'test_smbus',
  test_smbus,
  include_directories: include_dirs,
  dependencies: [
    gtest_dep,
    dev_deps,
    test_utilities_dep,
    test_utils_dep,
    internal_dep,
    complex_dep,
    libsmbus_dep,
  ]
  + libraries_dep,
  link_whole: drivers_dep,
)

test('component_drivers_test', component_drivers_test, timeout: 60)
test('mctp_service_test', mctp_service_test)
test('test_smbus', smbus_test)

# # 添加I2C测试子目录
subdir('drivers/bus/i2c')
subdir('drivers/bus/hisport')
subdir('drivers/chip/pca9545')
subdir('drivers/chip/pca9555')
subdir('drivers/chip/lm75')
subdir('drivers/accessor')
subdir('drivers/scanner')
subdir('drivers/chip/complex')
subdir('drivers/chip/eeprom')
subdir('drivers/chip/ads78')
subdir('drivers/chip/ina')
subdir('drivers/chip/interface/chip')
subdir('drivers/debounce')

# 添加gpu card 测试子目录
subdir('drivers/pcie_gpu_card')
subdir('drivers/pcie_nic_card/hisi')
subdir('drivers/pcie_nic_card/wx')
subdir('libraries/ncsi_over_mctp')
subdir('drivers/internal')